<template>
  <view
    class="content ba_img"
    :style="{
      'padding-top': height + 'px',
    }"
  >
    <view
      :style="{
        height: statusBarHeight + 'px',
      }"
    >
    </view>

    <view
      class="head"
      :style="{
        top: statusBarHeight + 'px',
      }"
    >
      <view class="head_left">
        <u-icon
          name="arrow-left"
          color="#eeeeee"
          size="24"
          :bold="true"
          @click="toBack"
        ></u-icon>
      </view>
      <view class="text">大成之道</view>
    </view>
    <scroll-view
      :style="{
        height: windowHeihgt + 'px',
      }"
      :scroll-y="true"
      @scroll="scroll"
    >
      <view class="box">
        <view class="box_item" v-for="item in list" @click="toDetail(item)">
          <view class="item_left">
            <view class="left_title">
              {{ item.name }}
            </view>
            <view class="left_time" v-if="item.jieshao">
              {{ item.jieshao }}
            </view>
            <view class="left_time">
              课程时间：{{ item.start_time }}-{{ item.end_time }}
            </view>
          </view>
          <view class="item_right">
            <u-icon name="arrow-right" color="#ADADAD" size="24"></u-icon>
          </view>
        </view>

        <view class="empty_view" v-if="list && list.length == 0">
          <image
            class="item_left_clickable"
            src="../../static/images/my/kong.png"
            mode=""
          ></image>
          <view>当前没有相关数据，请查看其他分类或功能。~</view>
        </view>
      </view>
    </scroll-view>
    <floatingBall></floatingBall>
  </view>
</template>

<script>
import { dacheng_list } from "@/common/api/dacheng.js";
export default {
  data() {
    return {
      statusBarHeight: 0,
      height: 0,
      windowHeihgt: 0,
      page: 1,
      list: [],
    };
  },
  created() {
    const statusBarHeight = uni.getSystemInfoSync(); // 获取手机状态栏高度
    this.statusBarHeight = statusBarHeight.statusBarHeight;
    this.$nextTick(() => {
      uni
        .createSelectorQuery()
        .select(".head")
        .boundingClientRect((data) => {
          this.height = data.height;
          this.windowHeihgt =
            statusBarHeight.windowHeight - data.height - this.statusBarHeight;
        })
        .exec();
    });
  },
  onLoad() {
    this.getList();
  },
  methods: {
    getList() {
      dacheng_list({
        page: this.page,
      })
        .then((res) => {
          console.log("resssss", res.data.list.data);
          this.list = res.data.list.data;
        })
        .catch((err) => {
          this.$u.toast(err);
        });
    },
    toBack() {
      uni.navigateBack({
        delta: 1,
      });
    },
    toDetail(item) {
      // uni.navigateTo({
      // 	url:"/pages/bigResult/school"
      // })

      uni.navigateTo({
        url: "/pages/training/detail?id=" + item.id + "&type=" + 2,
      });
    },
    scroll(e) {},
  },
};
</script> 

<style scoped lang="scss">
.ba_img {
  margin: 0;
  background: url("/static/images/index.png") no-repeat;
  background-size: 100% 100%;
  background-attachment: fixed;
  box-sizing: border-box;
}
.head {
  width: 100%;
  padding: 18rpx 0 47rpx;
  position: fixed;
  box-sizing: border-box;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 99;
  .head_left {
    position: absolute;
    left: 30rpx;
  }
  .text {
    font-size: 36rpx;
    font-family: PingFang SC-Bold, PingFang SC;
    font-weight: 400;
    color: #eeeeee;
  }
}
.box {
  width: 100%;
  padding: 0 30rpx;
  box-sizing: border-box;
  .box_item {
    width: 100%;
    padding: 32rpx;
    box-sizing: border-box;
    display: flex;
    background: rgba(39, 39, 39, 0.5);
    margin-top: 32rpx;
    border-radius: 16rpx;
    .item_left {
      flex: 1;
      .left_title {
        font-size: 30rpx;
        font-family: PingFang SC, PingFang SC;
        font-weight: 400;
        color: #eeeeee;
      }
      .left_time {
        font-size: 24rpx;
        font-family: PingFang SC, PingFang SC;
        font-weight: 400;
        color: #adadad;
        margin-top: 32rpx;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box; //设置排列方式为 弹性盒子排列方式
        -webkit-box-orient: vertical; //子元素排列方式  horizontal 横向排序;   vertical 纵向排序; inherit 继承父元素排序方式
        -webkit-line-clamp: 6; //显示多少行的内容
      }
    }
    .item_right {
      width: 68rpx;
      display: flex;
      justify-content: flex-end;
      align-items: center;
    }
  }
}

.empty_view {
  margin-top: 300rpx;
  image {
    margin: 0 auto;
    width: 410rpx;
    height: 410rpx;
  }
  view {
    font-size: 30rpx;
    color: #d8d8d8;
    text-align: center;
  }
}
</style>